<?php

class MenuDao extends Dao {

    public function injectDependencies() {

    }

    public function findAllAbleMenu($IDPerfil) {
        $this->initConnection();
        $this->tMysqli->escape($IDPerfil);
        $StSql = TQuery::getSqlFindAllAllowedMenu($IDPerfil);
        $MainMenu = new MainMenu();
        $tQuery = $this->tMysqli->exec($StSql);
        while($ArMenuData = mysqli_fetch_assoc($tQuery)) {
            $MainMenu->addMenu( new Menu($ArMenuData) );
        }
        $this->closeConnection();
        return $MainMenu;
    }

    public function findAllMenuAndSubmenuByProfile($IDPerfil) {
        $this->initConnection();
        $this->tMysqli->escape($IDPerfil);
        $StSql = TQuery::getSqlFindAllAllowedSubmenuByProfile($IDPerfil);
        $tQuery = $this->tMysqli->exec($StSql);
        $ArSubmenus = array();
        while( $ArSubmenuData = mysqli_fetch_assoc($tQuery) ) {
            $ArSubmenus[] = new Submenu($ArSubmenuData);
        }
        $this->closeConnection();
        return $ArSubmenus;
    }

}

?>
